package com.iflysse.services.impl;

import com.iflysse.dao.UserDao;
import com.iflysse.mapper.UserMapper;
import com.iflysse.pojo.Users;
import com.iflysse.pojo.bo.req.QueryUserInfoBoReq;
import com.iflysse.pojo.bo.req.UserBoReq;
import com.iflysse.pojo.bo.resp.QueryUserInfoBoResp;
import com.iflysse.pojo.bo.resp.UserBoResp;
import com.iflysse.pojo.po.req.UserPoReq;
import com.iflysse.pojo.po.resp.UserPoResp;
import com.iflysse.pojo.vo.req.ResetPasswordVoReq;
import com.iflysse.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public UserBoResp login(UserBoReq userBoReq) {
        //TODO 调用dao接口

        UserBoResp userBoResp=new UserBoResp();

        //TODO 根据用户信息，获取用户密码
        UserPoResp userPoResp = userMapper.login(userBoReq);

        //TODO 比对参数密码和数据库密码
        userBoResp.setRole(userPoResp.getRole());
        userBoResp.setUserId(userPoResp.getUserId());
        userBoResp.setToken("token自己设置");
        return userBoResp;
    }

    @Override
    public void resetPassword(ResetPasswordVoReq resetPasswordVoReq) {
        userMapper.resetPassword(resetPasswordVoReq);
    }

    @Override
    public List<Users> selectById(String accountNumber) {
        return userMapper.selectById(accountNumber);
    }

    @Override
    public List<Users> checkstuname_email(String student_name, String email) {
        return userMapper.checkstuname_email(student_name,email);
    }

    @Override
    public QueryUserInfoBoResp selectByBothId(QueryUserInfoBoReq queryUserInfoBoReq) {
        return userMapper.selectByBothId(queryUserInfoBoReq);
    }
}
